package com.kangye.enterprise.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.kangye.enterprise.entity.Department;
import com.kangye.enterprise.entity.Items;
import com.kangye.enterprise.entity.User;
import com.kangye.enterprise.mapper.ItemsMapper;
import com.kangye.enterprise.service.ItemsService;
import com.kangye.enterprise.util.ViewJsonObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @program: enterprise
 * @description: 实现类
 * @author: stl
 * @create: 2021-06-05 09:58
 **/
@Service
@Transactional
public class ItemsServiceImpl implements ItemsService {
    @Autowired
    private ItemsMapper itemsMapper;
    //查询用户的所有需要审核的项目(索腾龙)
    @Override
    public ViewJsonObject<Items> selUser(Integer page, Integer limit,Items items) {
        //把当前页和每页显示的条数传进来
        PageHelper.startPage(page, limit);
        //查询用户
        List<Items> list = itemsMapper.selItems(items);
        //创建分页对象,把数据存在pageInfo里
        PageInfo<Items> pageInfo = new PageInfo<Items>(list);
        //返回json页面
        return new ViewJsonObject<Items>(pageInfo.getList(), pageInfo.getTotal());
    }
    //查询全部部门
    @Override
    public ViewJsonObject<Department> selDepartments() {
        List<Department> list = itemsMapper.selDepartments();
        return new ViewJsonObject<>(list);
    }
}